{include file="public/header" /}
<style>
    .layui-form-pane .layui-form-label {
        text-align: right;
    }

    .layui-form-pane .layui-form-label em {
        display: inline-block;
        color: red;
    }
</style>
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="ibox float-e-margins">
        <div class="ibox-title">
            <h5>添加分类</h5>
        </div>
        <div class="ibox-content">
            <div class="example-wrap">
                <div class="example">
                    <form action="" class="layui-form layui-form-pane">
                        <div class="layui-form-item">
                            <label class="layui-form-label">名称<em>*</em></label>
                            <div class="layui-input-block">
                                <input type="text" class="layui-input" name="product_cate_name" placeholder="请输入分类名称"
                                       lay-verify="required" lay-verType="tips">
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <label class="layui-form-label">描述</label>
                            <div class="layui-input-block">
                                <textarea name="product_cate_remark" class="layui-textarea" placeholder="请输入描述"
                                          lay-verType="tips"></textarea>
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <label class="layui-form-label">状态<em>*</em></label>
                            <div class="layui-input-block">
                                <input type="radio" name="product_cate_status" value="1" title="开启" checked/>
                                <input type="radio" name="product_cate_status" value="0" title="关闭"/>
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <label class="layui-form-label">是否推荐<em>*</em></label>
                            <div class="layui-input-block">
                                <input type="radio" name="product_cate_tui" value="1" title="是">
                                <input type="radio" name="product_cate_tui" value="0" title="否" checked>
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <label class="layui-form-label">排序<em>*</em></label>
                            <div class="layui-input-block">
                                <input type="text" class="layui-input" name="product_cate_sort" value="10" min="1"
                                       placeholder="请输入品牌名称" lay-verify="required|number" lay-verType="tips">
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <button type="submit" class="layui-btn" lay-submit lay-filter="product_cate_add"><i
                                        class="fa fa-save"></i> 保存
                                </button>
                                <button type="button" class="layui-btn layui-btn-danger" onclick="history.go(-1);"><i
                                        class="fa fa-close"></i> 返回
                                </button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
{include file="public/footer" /}
<script type="text/javascript">
    var form = layui.form;

    /**
     * 添加
     */
    form.on('submit(product_cate_add)', function (data) {
        var param = data.field;
        var load = layer.load(2);
        $.post("{:url('product_cate_add')}", param, function (result) {
            layer.close(load);
            if (result.code === 200) {
                layer.msg(result.msg, {time: 1500,icon:1},function () {
                    location.href = "{:url('product/product_cate')}";
                });
            }else{
                layer.msg(result.msg, {time: 1500,icon:2});
            }
        });
        return false;
    });

</script>
</body>
</html>